www.mxdraw.com
|
返回块引用的属性文本
[helpstring("method AttributeItem")] HRESULT AttributeItem([in] LONG lItem, [out,retval] IMxDrawAttribute** ppAttribute);
参数 |
说明 |
[in] LONG lItem |
属性文本数组中的位置索引,从0开始计数的 |
例如: JS
function TestGetBlockAttrib() { var ss = mxOcx.NewSelectionSet(); var spFilte = mxOcx.NewResbuf(); // 把文字对象,当着过滤条件. spFilte.AddStringEx("INSERT", 5020); // 得到图上,所有文字对象. ss.CurrentSelect(spFilte); var str; for (var i = 0; i < ss.Count; i++) { var ent = ss.Item(i); if (ent == null) continue; if (ent.ObjectName == "McDbBlockReference") { var blkRef = ent; for (var j = 0; j < blkRef.AttributeCount; j++) { // 得到块引用中所有的属性 var attrib = blkRef.AttributeItem(j); str += attrib.TextString + "---" } } } alert(str); }
例如: VB代码
Private Sub readAttrib() AxMxDrawX1.OpenDwgFile("H:\A4图框.dwg") Dim ss As MxDrawXLib.MxDrawSelectionSet ss = New MxDrawXLib.MxDrawSelectionSet ss.AllSelect() Dim iNum As Long iNum = 0 Do While iNum < ss.Count Dim ent As MxDrawXLib.MxDrawEntity ent = ss.Item(iNum) If TypeOf ent Is MxDrawXLib.MxDrawBlockReference Then Dim blkRef As MxDrawXLib.MxDrawBlockReference blkRef = ent Dim iAttrib As Long iAttrib = 0 Do While iAttrib < blkRef.AttributeCount Dim attrib As MxDrawXLib.MxDrawAttribute attrib = blkRef.AttributeItem(iAttrib) attrib.TextString = attrib.TextString + "-test" iAttrib = iAttrib + 1 Loop blkRef.AssertWriteEnabled() End If iNum = iNum + 1 Loop End Sub